import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
      num:null,
  },
  mutations: {
    getlist(state,payload){
        state.num = payload.data.length
        if(state.num===0){
            state.num = null
        }
    }
  },
  actions: {
    async getCartList({commit}){
        //获取购物车数据
        let rs = await getCartList({});
        // this.num = rs.data.length;
        // if(this.num===0){
        //     this.num = null
        // }
        commit("getlist", rs)
    },
  },
  
  modules: {
  }
})
